<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
</head>

<body>
    <script type="text/javascript">
    function shallowCopy(src) {
        var dst = {}
        for (var i in src) {
            dst[i] = src[i]
        }
        return dst
    }
    var obj = { a: 1, b: [1, 2, 3], c: { c1: 12 } }
    var newObj = shallowCopy(obj)
    var deepObj = deepCopy(obj)
    obj.c=123
    console.log(deepObj);
    console.log(obj)
    console.log(newObj)
    
    
    function deepCopy(o, c) {
        var c = o.constructor === Array ? [] : {}
        for (let key in o) {
            if (o.hasOwnProperty(key)){
                    if (o[key] && typeof o[key] == 'object') {
                        c[key]=o[key].constructor === Array ? [] : {};
                        c[key]=deepCopy(o[key])
                    }else{
                        c[key]=o[key]
                    }
                }
        }
        return c
    }
    </script>
</body>

</html>